<?php /*
	*/ ?>
<?php include("inc/head.inc.php"); ?>
<?php
// update for pr view -start
if(isset($_REQUEST['proid']) && ($_REQUEST['proid'])!="")
{
	$productid=$_REQUEST['proid'];
}
$sqlupd="update `tblproddesc` set `intprodviewed`=`intprodviewed` +1 WHERE `intid`='$productid'";
$upd=$n02586916_db->edit($sqlupd);
// update for pr view -end

if(isset($_REQUEST['Submit']) && ($_REQUEST['Submit'])=='Submit Review')
{
	$subject=mysql_real_escape_string($_REQUEST['subject']);
	$desc=mysql_real_escape_string($_REQUEST['desc']);
	$radiobutton=mysql_real_escape_string($_REQUEST['radiobutton']);
	$sqlmem="select * from tblcustomers where intcusid='".$_SESSION['memberid']."'";
	$resmem=$n02586916_db->select($sqlmem);
	$memmailid=$resmem[0]['varcustemail'];
	$varcustfname=$resmem[0]['varcustfname'];
	$ip=$_SERVER['REMOTE_ADDR'];
	$insert="INSERT INTO 		    
	tblratings(`intrateto`,`varratefromemail`,`varratefromname`,`intrate`,
	`varcomments`,`varrateip`,`ttrated`) VALUES 
	('$productid','$memmailid','$varcustfname','$radiobutton','$desc','$ip',now())";
	$ins=$n02586916_db->insert($insert);
}
?>
<body>
<table width="824" border="0" cellpadding="0" cellspacing="0"  align="center">
  
  <tr>
   <td class="headerclass"><?php include(INC."top.inc.php") ?></td>

  </tr>
  <tr>
    <td valign="top" class="maincontainer"><table width="100%" border="0" cellpadding="0" cellspacing="0">
      <tr><td width="235" valign="top"class="leftmenuback"><?php include(INC."left.inc.php")?></td>
        <td valign="top">
		<div class="pageheader">Product Detail</div>
		
		<table width="100%" border="0" align="center" cellpadding="0" cellspacing="0" >
        
        <tr>
		<?php 
		if(isset($_REQUEST['proid']) && ($_REQUEST['proid'])!=""){
			$productid=$_REQUEST['proid'];
		} else {
			echo '<span class="msg">No Detail Found for this Product</span>';
		}	
		?>
          <td style="padding-left:5px"><form action="shopping_cart.php?action=2&proid=<?php echo $productid;?>" method="post" name="cart">
		  <table  width="99%" border="0" cellpadding="0" cellspacing="1" class="proborder">
      <?php 
	  	if(isset($_REQUEST['proid']) && ($_REQUEST['proid'])!="")
		{
			$productid=mysql_real_escape_string($_REQUEST['proid']);
			$sqlpr="select * from tblproducts where intprodid='$productid'";
			$respr=$n02586916_db->select($sqlpr);
			if($respr)
			{
				$id=stripslashes($respr[0]['intprodid']);
				$proprice=stripslashes($respr[0]['decprice']);
				
			$sqlprodesc="select * from tblproddesc where intid='$productid'";
			$resimg=$n02586916_db->select($sqlprodesc);
	  ?>
	  	<tr>
        <td height="23" colspan="4">
			
	  </td>
      </tr>
      <tr>
        <td height="23" colspan="3" style="border:1px solid #999999;" class="fntstyle" bgcolor="#CCCCCC">&nbsp;&nbsp;<?php echo stripslashes($resimg[0]['varprodname']);?></td>
        <td height="23" align="center" style="border:1px solid #999999;" bgcolor="#CCCCCC" class="prborderbg" id="proprice">&nbsp;&nbsp;&nbsp;
		<span name="price" id="price" class="price">&pound;<?php echo stripslashes($respr[0]['decprice']);?></span>
		</td>
      </tr>
      <tr>
        <td colspan="3" align="left" valign="top" class="font" ><?php echo stripslashes($resimg[0]['txtdesc']);?></td>
        <?php
		if (file_exists("images/product/midium/".$respr[0]['intproddefaultimg'])) { 
			$image="images/product/midium/".$respr[0]['intproddefaultimg'];
			$largeimage="images/product/big/".$respr[0]['intproddefaultimg'];
		} else { 
			$image="images/product/midium/noimage.jpg";
			$largeimage="images/product/midium/noimage.jpg";
		}		
		?>
        <td width="23%" align="center" valign="top">
		<img src="<?php echo $image;?>" style="cursor:hand"  alt="<?php echo $respr[0]['intproddefaultimg'];?>" onClick="popup_show('popup2', 'popup_drag2', 'popup_exit2', 'screen-corner', 480,290);" />
		</td>
      </tr>
      <tr>
	  <td width="50%" colspan="3" class="font" style="padding-left:10px"> 
	  <strong>Product options</strong><br />
<table border="0" cellspacing="0" cellpadding="5" colspan="3">
<?php
		$titlesql = "SELECT DISTINCT tblproductattributes.intoptionid FROM tblproductattributes WHERE intproductid='".$id."'";
		$titleresults=$n02586916_db->select($titlesql);
		if($titleresults) {
			for($a=0;$a<count($titleresults);$a++) {
				$optionresults="";
				$ab="";
				$nameresults="";
				$namesql = "SELECT varoptionvaluename FROM tbloptionvalues WHERE intid=".$titleresults[$a]['intoptionid'];
				$nameresults=$n02586916_db->select($namesql);
				$optionid = $a+1;
				echo "<tr><td>".$nameresults[0]['varoptionvaluename']."</td>";
				echo "<td><select name=\"prodoptions".$optionid."\" id=\"prodoptions".$optionid."\">";
				$optionsql = "SELECT tblproductattributes.*,tblproductoptions.* FROM `tblproductattributes` INNER JOIN tblproductoptions ON tblproductattributes.intoptionvalueid=tblproductoptions.intid WHERE tblproductattributes.intoptionid=".$titleresults[$a]['intoptionid']." AND tblproductattributes.intproductid='$id' ORDER BY `decprice` ASC";
				echo $optionsql;
				$optionresults=$n02586916_db->select($optionsql);
					for($ab=0;$ab<count($optionresults);$ab++) {
						echo "<option value=\"".$optionresults[$ab]['intattributeid']."\">".stripslashes($optionresults[$ab]['varoptionname'])." (".$optionresults[$ab]['charprefix']." ".$optionresults[$ab]['decprice'].")</option>";
					}
				echo "</select></td></tr>";
			} 
			$totaloptions = $a;
			echo "<input type=\"hidden\" name=\"totoptions\" id=\"totoptions\" value=\"$totaloptions\" />";
		} else {
			echo "<tr><td>No options for this product</td></tr>";
		}
?>
</table>
	  </td>
        <td align="center" valign="top"><img src="images/enlarge.gif" style="cursor:hand" border="0" alt="Enlarge" onClick="popup_show('popup2', 'popup_drag2', 'popup_exit2', 'screen-corner', 480,290);" /><br /><a href="productimages.php?proid=<?php echo $productid;?>" class="aa"><img src="images/moreimages.jpg" border="0" alt="More Images" /></a><br /><a href="mywishlist.php?product=<?php echo $productid;?>&act=addtowish" onClick="return confirm('Do you want to add this product in to your Wishlist?')"><img src="images/wish.jpg" border="0" alt="Add to Wishlist" /></a><br />
		<?php
		if(isset($_SESSION['memberid']) && ($_SESSION['memberid'])!="")
		{
		?>
		<a href="#" onClick="return showhide('rate');"><img src="images/review.jpg" alt="REVIEW" width="80" height="17" border="0" /></a>
		<?php }else{ ?>
		<a href="customerlogin.php"><img src="images/review.jpg" alt="REVIEW" width="80" height="17" border="0" /></a>
		<?php }?>
	 </td>
      </tr>
      <tr>
        <td colspan="3" class="font" style="padding-left:10px"><strong>Product Code:</strong><span class="font"><?php echo $id;?></span>
		&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
		<span class="msg1">
          <?php 
			  $sqlw="select tblprodgiftideas.*,tblideas.* from tblprodgiftideas,tblideas where intprodid='$id' and tblprodgiftideas.intgiftideaid=tblideas.intid";
		  		$resw=$n02586916_db->select($sqlw);
				if($resw)
				{
				$offer= stripslashes($resw[0]['vargiftideatitle']);
				}
				else{$offer="";}
				?>
				<?php echo stripslashes($offer);?></span>	&nbsp;</td>
        <td height="20" align="center" valign="middle">
		</td>
      </tr><?php }else{echo '<span class="msg">No Details Found</span>';}}?>
      <tr>
        <td colspan="2" align="center"><a href="<?php echo $_SERVER['HTTP_REFERER'];?>" class="ab"><img src="images/back.gif" border="0" alt="BACK" /></a></td>
        <td align="center"><a href="products.php" class="ab"><img src="images/continue.gif" alt="Continue Shopping" width="91" height="22" border="0" /></a></td>
        <td align="center" valign="middle">
		<input type="image" src="images/addtocart.gif" value="Add to Cart" />
		</td></tr>
    </table> </form>
	<br />
	<form method="post" action="proddetail.php?proid=<?php echo $productid;?>" name="frm">
		<table id="rate" width="100%"  border="0" cellspacing="0" cellpadding="3" class="border" style="display:none;">
              <tr>
                <td colspan="2" align="left" class="fntstyle">Add your review</td>
                </tr>
              <tr>
                <td align="left" class="fntstyle">&nbsp;</td>
                <td align="left" class="fntstyle">&nbsp;</td>
              </tr>
              <tr>
                <td align="left" class="font"><strong>Subject : </strong></td>
                <td align="left" class="font"><input name="subject" type="text" id="subject" size="50" /></td>
              </tr>
              <tr>
                <td align="left" valign="top" class="font"><strong>Comment :</strong> </td>
                <td align="left" class="font"><textarea name="desc" cols="50" rows="5" id="desc"></textarea></td>
              </tr>
              <tr>
                <td align="left" class="fntstyle">Rate : </td>
                <td align="left" class="fntstyle">Poor
                    <input name="radiobutton" type="radio" value="1" />
                    <input name="radiobutton" type="radio" value="2" />
                    <input name="radiobutton" type="radio" value="3" />
                    <input name="radiobutton" type="radio" value="4" />
                    <input name="radiobutton" type="radio" value="5" />
                  Best</td>
              </tr>
              <tr>
                <td>&nbsp;</td>
                <td><input type="submit" name="Submit" value="Submit Review" onClick="return rating();" /></td>
              </tr>
        </table>
	</form>	
		<?php 
		if(isset($_REQUEST['proid']) && ($_REQUEST['proid'])!="")
		{
			$productid=$_REQUEST['proid'];
			$sql="select * from tblrelatedproduct where intprodid='$productid' limit 0,2";
				$res=$n02586916_db->select($sql);
				if(count($res)>0)
				{
		?>	
			<div class="pageheader">Related Items</div>			
			<table width="100%" border="0" cellpadding="0" cellspacing="1" class="proborder">
			<tr>
              <td height="23" colspan="4" class="feature_headingbg">&nbsp;&nbsp;&nbsp; &nbsp; </td>
              </tr>
			<?php 
					for($rp=0;$rp<count($res);$rp++)
					{
					$prid=$res[$rp]['intrelatedid'];
					
					
			?>
            <tr>
              <td width="22%">&nbsp;&nbsp;&nbsp;<a href="proddetail.php?proid=<?php echo $prid;?>" class="aa"><?php $sqlprname="select intproddefaultimg from tblproducts where intprodid='$prid'";
					$resprname=$n02586916_db->select($sqlprname);
					
					if($resprname)
					{
					?><img src="images/product/<?php echo $resprname[0]['intproddefaultimg'];?>" alt="product"  border="0"/><?php }?></a></td>
              <td width="22%" align="center" class="font"><a href="proddetail.php?proid=<?php echo $res[$rp]['intrelatedid'];?>" class="aa">
                <strong>
				<?php
				$sqlrp="select `varprodname`,`txtdesc` from `tblproddesc` where `intid`='$prid'";
				$respr=$n02586916_db->select($sqlrp);
				if($respr) {
					echo stripslashes($respr[0]['varprodname']);
					$prodiscription=stripslashes($respr[0]['txtdesc']);
				}
				?></strong>
              </a></td>
              <td width="35%" align="center" class="font"><?php
			  if(strlen($prodiscription)>20) {
			  	$temp=substr($prodiscription,0,20);
				echo $temp."...";
			  } else {
			  echo stripslashes($prodiscription);}
			  ?></td>
              <td width="21%" align="left" class="fontsmall"><a href="proddetail.php?proid=<?php echo $prid;?>"><img src="images/buynow.jpg" border="0"/></a></td>
            </tr><?php }?>
          </table>
		  <?php } }?>          
		  <br /><br />
		  <div class="pageheader">Customer Reviews</div>
			  	<?php 
					$reviewsql="select * from `tblratings` where `intrateto`='".$_REQUEST['proid']."'";
					$reviewresults=$n02586916_db->select($reviewsql);
					if(count($reviewresults)>0) {
						for($rv=0;$rv<count($reviewresults);$rv++) {
						echo "<div class=\"sortoptions\"><table width=\"100%\" border=\"0\" cellpadding=\"0\" cellspacing=\"2\" class=\"proborder\"><tr><td>";
						echo stripslashes($reviewresults[$rv]['varcomments']);
						echo "<br /><br />";
						echo "<div style=\"float:left;\">Rating: ".stripslashes($reviewresults[$rv]['intrate'])."</div><div style=\"float:right;\">Review by: ".stripslashes($reviewresults[$rv]['varratefromname'])."</div>";
						echo "</td></tr></table></div>";
						}
					} else { 
						echo "<div class=\"sortoptions\"><table width=\"100%\" border=\"0\" cellpadding=\"0\" cellspacing=\"2\" class=\"proborder\"><tr><td>No customers have reviewed this product yet be the first to review it.</td></tr></table></div>";
					}
				?>		  
		  </td>
        </tr> 
    </table>
		</td>
      </tr>
    </table>
    </td>
  </tr>
  <tr>
    <td><?php include "inc/bottom.inc.php"; ?></td>
  </tr>
</table>
<div class="sample_popup" id="popup2" style="visibility: hidden; display: none;">
                <div class="menu_form_header" id="popup_drag2"> <img class="menu_form_exit"  id="popup_exit2" src="images/closepop.jpg" />Product Image </div>
                <div class="menu_form_body" style="overflow: auto; width: 500px; height: 370; border-left: 1px black solid; border-bottom: 1px black solid; padding:0px; margin: 0px">
					 <img src="<?php echo $largeimage;?>" align="center" />
                </div>
</div>
</body>
</html>
